package cn.xs.order.entity;

import java.util.UUID;

import cn.xs.goods.entity.Good;

/**
 * 一个订单项里面有一种商品,商品数量不限
 *
 */
public class OrderItem {

	private String id;
	private int quantity;
	private String good_id;
	private String order_id;
	private double price;	//小计
	
	private Order order;
	private Good good;
	
	
	/**
	 * 使用这个的构造函数,不用考虑id,order_id,price和good_id,会自动生成
	 * @param quantity
	 * @param order
	 * @param good
	 */
	public OrderItem(Good good,int quantity, Order order ) {
		this.good = good;
		this.order = order;
		this.quantity = quantity;
		//--auto create
		this.id = UUID.randomUUID().toString();
		this.order_id = order.getId();
		this.good_id = good.getId();
		this.price = quantity * good.getPrice();
	}
	/**
	 * 使用这个的构造函数,不用考虑id,order_id,price和good_id,会自动生成
	 * @param quantity
	 * @param order
	 * @param good
	 */
	public OrderItem(CarItem item,Order order){
		this.good_id = item.getGood().getId();
		this.quantity = item.getQuantity();
		this.order_id = order.getId();
		this.price = item.getPrice();
		this.id = item.getId();
	}
	
	public OrderItem() {
		// TODO Auto-generated constructor stub
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public int getQuantity() {
		return quantity;
	}
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	public String getGood_id() {
		return good_id;
	}
	public void setGood_id(String goodId) {
		good_id = goodId;
	}
	public String getOrder_id() {
		return order_id;
	}
	public void setOrder_id(String orderId) {
		order_id = orderId;
	}
	public Order getOrder() {
		return order;
	}
	public void setOrder(Order order) {
		this.order = order;
	}
	public Good getGood() {
		return good;
	}
	public void setGood(Good good) {
		this.good = good;
	}
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}	
	
	
}
